From 709236d92f4ff9508042d6762a235c6fe40df1ba Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 15 Sep 2008 06:42:24 +0000 Subject: [PATCH] Rough in Garmin protocol "file" support for Windows. Crashes inside the XML parser, of all places. Will recheck on Mac soon to ensure that recent UTF-8 changes didn't hose us. --- jeeps/gpsusbwin.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/jeeps/gpsusbwin.c b/jeeps/gpsusbwin.c index c87e3de6e..b0b087c18 100644 --- a/jeeps/gpsusbwin.c +++ b/jeeps/gpsusbwin.c @@ -31,6 +31,7 @@ #include "gpsapp.h" #include "garminusb.h" #include "gpsusbcommon.h" +#include "../garmin_device_xml.h" /* Constants from Garmin doc. */ @@ -54,6 +55,7 @@ typedef struct { static HANDLE *usb_handle = INVALID_HANDLE_VALUE; static int usb_tx_packet_size ; +static const gdx_info *gdx; static int gusb_win_close(gpsdevh *handle) @@ -182,6 +184,29 @@ HANDLE * garmin_usb_start(HDEVINFO* hdevinfo, SP_DEVICE_INTERFACE_DATA *infodata return usb_handle; } + +static char ** get_garmin_mountpoints() { +#define BUFSIZE 512 + TCHAR szTemp[MAX_PATH]; + char *p = szTemp; + char **dlist = xmalloc(0); + int i = 0; + + fprintf(stderr, "eek!\n"); + if (GetLogicalDriveStrings(BUFSIZE-1, szTemp)) + { + while(*p) { + dlist = xrealloc(dlist, sizeof (*dlist ) * ++i); + // fprintf(stderr, "Found: %d, %s\n", i, p); + dlist[i-1] = xstrdup(p); + dlist[i] = NULL; + while (*p++); + } + } + + return dlist; +} + /* * Main entry point from the upper layer. Walk the device tree, find our * device, and light it up. @@ -224,8 +249,17 @@ gusb_init(const char *pname, gpsdevh **dh) if (!SetupDiEnumDeviceInterfaces(hdevinfo, NULL, (GUID *) &GARMIN_GUID, req_unit_number, &devinterface)) { + // If there were zero matches, we may be trying to talk to a "GPX Mode" device. + + + char **dlist = get_garmin_mountpoints(); + gdx = gdx_find_file(dlist); + if (gdx) return 1; + + + // Plan C. GPS_Serial_Error("SetupDiEnumDeviceInterfaces"); - warning("Is the Garmin USB unit number %d powered up and connected?\nIs it really a USB unit? If it's serial, don't choose USB, choose serial.\nAre the Garmin USB drivers installed and functioning with other programs?\nIs it a storage based device like Nuvi, CO, or OR?\n If so, send GPX files to it, don't use this module.", un); + warning("Is the Garmin USB unit number %d powered up and connected?\nIs it really a USB unit? If it's serial, don't choose USB, choose serial.\nAre the Garmin USB drivers installed and functioning with other programs?\nIs it a storage based device like Nuvi, CO, or OR?\n If so, send GPX files to it, don't use this module.\n", un); return 0; } /* We've matched. Now start the specific unit. */ @@ -241,8 +275,10 @@ gusb_init(const char *pname, gpsdevh **dh) if (!SetupDiEnumDeviceInterfaces(hdevinfo, NULL, (GUID *) &GARMIN_GUID, match, &devinterface)) { if (GetLastError() == ERROR_NO_MORE_ITEMS) { + break; } else { + GPS_Serial_Error("SetupDiEnumDeviceInterfaces"); warning("Is the Garmin USB unit number %d powered up and connected?", un); return 0; -- 2.30.2